<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    <button @click="addRandomNumber">生成</button>
    <ul>
      <li v-for="(item, index) in items" :key="index">
        {{ item }}
        <button @click="removeItem(index)">删除</button>
      </li>
    </ul>
  </div>
  <script src="../vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        items: []
      },
      methods: {
        addRandomNumber() {
          const randomNumber = Math.floor(Math.random() * 20) + 1; 
          this.items.push(randomNumber);
        },
        removeItem(index) {
          this.items.splice(index, 1); 
        }
      }
    })
  </script>
</body>

</html>